package com.android.yummycookies.types;

import java.util.HashSet;
import java.util.Set;

import android.graphics.Bitmap;

import com.android.yummycookies.R;
import com.android.yummycookies.commonInterface.ILoadableRessource;
import com.android.yummycookies.commonInterface.IScalableLoadableRessource;
import com.android.yummycookies.model.cookie.CookieSprite;
import com.android.yummycookies.model.cookie.CookieSpriteFactory;

public enum CookieType implements ILoadableRessource,
		IScalableLoadableRessource {

	CHECKERBOARD_COOKIE(R.string.checkerBoardCookie,
			R.string.checkerBoardCookieDescritpion,
			R.drawable.checkeroard_cookie, SpriteType.SIMPLE_SPRITE,
			R.drawable.checkeroard_cookie, SpriteType.SIMPLE_SPRITE),
	// FLOWER_COOKIE(R.string.flowerCookie, R.string.flowerCookieDescritpion,
	// 0),
	DONUT_COOKIE(R.string.donutCookie, R.string.donutCookieDescritpion,
			R.drawable.donut, SpriteType.SIMPLE_SPRITE, R.drawable.donut,
			SpriteType.SIMPLE_SPRITE);
	// HEART_COOKIE(R.string.heartCookie, R.string.heartCookieDescritpion, 0),
	// SQUARE_COOKIE(R.string.squareCookie, R.string.squareCookieDescription,
	// 0),
	// JOCKER_COOKIE(R.string.jockerCookie, R.string.jockerCookieDescription,
	// 0);

	/**
	 * Informations textuelle du cookie
	 */
	private final int nameId;
	private final int descriptionId;

	/**
	 * Sprite d'affichage pour le plateau
	 */
	private final int bitmapId;
	private Bitmap bitmap;
	private final SpriteType spriteType;
	private CookieSprite sprite;

	/**
	 * Sprite d'affichage de destruction
	 */
	private final int destructionBitmapId;
	private Bitmap destructionBitmap;
	private final SpriteType destructionSpriteType;
	private CookieSprite destructionSprite;

	private CookieType(int nameId, int descriptionId, int bitmapId,
			SpriteType spriteType, int destructionBitmapId,
			SpriteType destructionSpriteType) {

		this.nameId = nameId;
		this.descriptionId = descriptionId;

		this.bitmapId = bitmapId;
		this.spriteType = spriteType;

		this.destructionBitmapId = destructionBitmapId;
		this.destructionSpriteType = destructionSpriteType;
	}

	public int getNameId() {
		return nameId;
	}

	public int getDescriptionId() {
		return descriptionId;
	}

	public int getBitmapId() {
		return bitmapId;
	}

	public Bitmap getBitmap() {
		return bitmap;
	}

	public SpriteType getSpriteType() {
		return spriteType;
	}

	public CookieSprite getSprite() {
		return sprite;
	}

	public int getDestructionBitmapId() {
		return destructionBitmapId;
	}

	public Bitmap getDestructionBitmap() {
		return destructionBitmap;
	}

	public SpriteType getDestructionSpriteType() {
		return destructionSpriteType;
	}

	public CookieSprite getDestructionSprite() {
		return destructionSprite;
	}

	public void setBitmap(Bitmap bitmap) {
		this.bitmap = bitmap;
		sprite = CookieSpriteFactory.createSprite(spriteType, bitmap);
	}

	public void setDestructionBitmap(Bitmap destructionBitmap) {
		this.destructionBitmap = destructionBitmap;
		sprite = CookieSpriteFactory.createSprite(destructionSpriteType,
				destructionBitmap);
	}

	@Override
	public Set<Integer> getBitmapsId() {
		HashSet<Integer> bitmapsToLoad = new HashSet<Integer>();

		bitmapsToLoad.add(bitmapId);
		bitmapsToLoad.add(destructionBitmapId);

		return bitmapsToLoad;
	}

	@Override
	public Set<Integer> getScalableBitmapsId() {
		return getBitmapsId();
	}

}
